import React from 'react';
import { connect } from 'dva';
import { history } from 'umi'


const LoginPage = (props) => {
    const { dispatch } = props;
    const goLogin = () => {
        dispatch({
            type: 'common/goLogin',
            payload: {
              username: 'lingsang',
              password: '123',
            }
          }).then((res) => {
            if(res.code == 200){
              alert('登录成功！')
              history.push('/')
              localStorage.setItem('token_umi_app', 'lingsang')
              dispatch({
                type: 'common/getUserInfo',
              })
            }
          })
    }
    return (
        <div>
            <button onClick={goLogin}>Go Login!!</button>
        </div>
    )
}
export default connect()(LoginPage)